#ifndef ADVANCEDCONFIG_H
#define ADVANCEDCONFIG_H

#include <QWidget>
#include <QMap>
#include <QString>
#include <QTableWidget>
#include <QStringList>
#include <QButtonGroup>
#include <QRadioButton>
#include <QSpacerItem>
#include "posiPannel.h"
#include "qpcrModel.h"

namespace Ui {
class AdvancedConfig;
}



class AdvancedConfig : public QWidget
{
    Q_OBJECT

public:
    explicit AdvancedConfig(int rowNum, int colNum, QWidget *parent = nullptr);
    ~AdvancedConfig();


// 接口定义 (QML和QWidget通用接口) ------------------------------------->
public:
    void setParamsList(QMap<QString, QMap<QString, double>> states);
    void setSelectableList(QStringList);    // 设置了的孔位列表
    void setFittedList(QVector<QStringList>);        // 拟合成功的曲线列表，未拟合的内容会被置灰

signals:
    void sigReanalysis(QStringList, QMap<QString, double>);
    void sigSelectCurveChanged(QStringList);
    void sigCancel();
// 接口定义结束 ------------------------------------------------------->

private slots:
    void on_radioButton_open_clicked();
    void on_radioButton_close_clicked();
    void on_radioButton_CY5_clicked();
    void on_radioButton_FAM_clicked();
    void on_radioButton_ROX_clicked();
    void on_radioButton_VIC_clicked();
    void on_pushButton_reanalysis_clicked();
    void on_pushButton_setDefault_clicked();

    void on_selectPosiChanged(QStringList);

    void on_pushButton_single_clicked();

    void on_pushButton_channel_clicked();

    void on_pushButton_cancel_clicked();

    void on_pushButton_clear_clicked();

private:
    void state2edit();
    void edit2state();
    void updatePannelSelectable();
    void updateEditorState();

    void showEvent(QShowEvent *event) override;

private:

    QStringList getSelectedNameList(QStringList);

    Ui::AdvancedConfig *ui;

    QStringList     _selectableList;        // 孔位列表
    QVector<QStringList>     _fittedLists;            // 孔位列表 + 通道列表
    QMap<QString, QMap<QString, double>> _states;       // 单个曲线的配置
//    QMap<QString, QMap<QString, double>> _states_channel;     // 整个通道的配置

//    int             _changeMode = 0;   // 0:单个孔位修改  1:单个通道修改

    int             _row;
    int             _col;

    QStringList     _curPosi;
    QString         _curChannel = "FAM";

    PosiPannel*      _posiPannel;

    QButtonGroup*   _buttonGroup_channel;
    QButtonGroup*   _buttonGroup_fixedBaseline;
    QMap<QString, double> _defaultConfig;


};

#endif // ADVANCEDCONFIG_H
